<?php

/**
 * @Author Phan Tan Dung(phantandung92@gmail.com)
 * @Copyright freeware
 * @Createdate 22/1/2011 00:00
 */
if ( ! defined( 'NV_MAINFILE' ) ) die( 'Stop!!!' );

if ( ! function_exists( 'nv_albums' ) )
{
	function nv_albums ( )
    {
		global $global_config, $module_name, $module_data, $module_file, $global_array_cat, $module_config, $module_info, $db, $my_head;
	
		$my_head .= "<link rel=\"Stylesheet\" href=\"" . NV_BASE_SITEURL . "js/albums/divbox.css\" />\n";
		$my_head .= "<script type=\"text/javascript\" src=\"" . NV_BASE_SITEURL . "js/albums/easySlider1.5.js\"></script>\n";
		$my_head .= "<script type=\"text/javascript\" src=\"" . NV_BASE_SITEURL . "js/albums/divbox.js\"></script>\n";
		$my_head .= "<script type=\"text/javascript\" src=\"" . NV_BASE_SITEURL . "js/albums/jquery.ui.draggable.js\"></script>\n";

		$sql = "SELECT * FROM `" . NV_PREFIXLANG . "_albums_album` WHERE active = 1 ORDER BY weight ASC LIMIT 0,1";
		$aID = $db->sql_fetchrow( $db->sql_query( $sql ) );

		$sqlpic = "SELECT * FROM `" . NV_PREFIXLANG . "_albums_picture` WHERE `albumid` = " . $aID['albumid'] . " ORDER BY `weight` ASC";
		$picdata = $db->sql_query( $sqlpic );

		$xtpl = new XTemplate( "global.block_albums.tpl", NV_ROOTDIR . "/themes/" . $module_info['template'] . "/blocks" );
		$i = 1;
		while ( $pic = $db->sql_fetchrow( $picdata ) )
		{
			$xtpl->assign( 'PIC', $pic );
			if ( $i <= 5 )
			{
					$xtpl->parse( 'main.top' );
			}
			else
			{
				$xtpl->parse( 'main.bottom' );			
			}
			$i ++;
		}
		$xtpl->parse( 'main' );
		return $xtpl->text( 'main' );

	}
	$content = nv_albums( );
}
?>